package com.petmall.mapper;

import java.util.List;
import com.petmall.entity.Message;
import org.apache.ibatis.annotations.*;

/**
 * Created by pig2guang on 2017/4/3.
 */
@Mapper
public interface MessageMapper {

    @Select("select * from tb_message")
    public List<Message> selectAllMessage();

    @Insert("insert into tb_message(type,user_id,message,update_time,receiver,order_id) values(#{type}, #{user_id}, #{message}, #{update_time}, #{receiver}, #{order_id})")
    public void insertMessage(@Param("type") int type, @Param("user_id") long user_id, @Param("message") String message, @Param("update_time") String update_time, @Param("receiver") int receiver, @Param("order_id") String order_id);

    @Select("select * from tb_message where user_id = #{user_id} and receiver = #{receiver} order by update_time desc")
    public List<Message> selectUserAllMessage(@Param("user_id") long user_id, @Param("receiver") int receiver);

    @Select("select * from tb_message where receiver = #{receiver} order by update_time desc")
    public List<Message> selectAdminAllMessage(int receiver);

    @Delete("delete from tb_message where id = #{id}")
    public void deleteMessage(long id);

}
